//
//  MyMenuButton.cpp
//  CanYouDoIt
//
//  Created by hoangtx on 7/6/13.
//
//

#include "MyMenuButton.h"



bool MyMenuButton::init(){
    return true;
}

MyMenuButton* MyMenuButton::create(const char *contentString, double mX, double mY, double mWidth, double mHeight){
    MyMenuButton* button = MyMenuButton::create();
    button->setPosition(ccp(mX,mY));
    button->buttonSize = CCSizeMake(mWidth, mHeight);
    button->backgroundSprite = CCSprite::create("menu_button_background.png");
    button->backgroundSprite->setAnchorPoint(ccp(0,0));
    button->backgroundSprite->setScaleX(mWidth/button->backgroundSprite->getContentSize().width);
    button->backgroundSprite->setScaleY(mHeight/button->backgroundSprite->getContentSize().height);
    button->backgroundSprite->setPosition(ccp(0,0));
    button->addChild(button->backgroundSprite);
    
    button->contentLabel = CCLabelBMFont::create(contentString, "Info.fnt");
    button->contentLabel->setAnchorPoint(ccp(0.5,0.5));
    button->contentLabel->setPosition(mWidth/2,mHeight/2);
    button->contentLabel->setScale(mHeight*0.5f/button->contentLabel->getContentSize().height);
    button->contentLabel->setColor(ccc3(0,0,0));
    button->addChild(button->contentLabel);

    return button;
}

void MyMenuButton::goToHighlightMode(){
    contentLabel->setColor(ccc3(90,212,34));
}

void MyMenuButton::goToNormalMode(){
    contentLabel->setColor(ccc3(0,0,0));
}

bool MyMenuButton::isTouchedAt(cocos2d::CCPoint touchPosition){
    
    return getBoundingRect().containsPoint(touchPosition);
}